package com.example.alibabavodossservice.oss;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author xugenyin
 */
@Component
@Data
public class OssConfig implements InitializingBean {

    public static final String BASE_PATH = "docuhub/oss/";
    @Value("${AliYun.endpoint}")
    private String oss_endpoint;
    @Value("${AliYun.keyId}")
    private String oss_keyId;
    @Value("${AliYun.keySecret}")
    private String oss_keySecret;
    @Value("${AliYun.bucketName}")
    private String oss_bucketName;
    @Value("${AliYun.berrontech}")
    private String berrontech;


    //定义公开静态常量

    public static String OSS_END_POINT;
    public static String OSS_ACCESS_KEY_ID;
    public static String OSS_ACCESS_KEY_SECRET;
    public static String OSS_BUCKET_NAME;
    public static String BUCKET_ALL_NAME;
    public static String BEERONTECH;
    public static String LAST_URL;


    @Override
    public void afterPropertiesSet() {
        OSS_END_POINT = oss_endpoint;
        OSS_ACCESS_KEY_ID = oss_keyId;
        OSS_ACCESS_KEY_SECRET = oss_keySecret;
        OSS_BUCKET_NAME = oss_bucketName;
        BEERONTECH = berrontech;
        LAST_URL = "http://" + berrontech + "/";
        BUCKET_ALL_NAME = "http://" + oss_bucketName + "." + oss_endpoint + "/";

    }
}
